
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Leo in 10 Minutes &#8212; Leo 6.7.2 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/classic.css" />
    <link rel="stylesheet" type="text/css" href="_static/custom.css" />
    
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/sphinx_highlight.js"></script>
    
    <script src="_static/sidebar.js"></script>
    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Using Leo as a Personal Information Manager" href="tutorial-pim.html" />
    <link rel="prev" title="Leo’s Tutorials" href="tutorial.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="tutorial-pim.html" title="Using Leo as a Personal Information Manager"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="tutorial.html" title="Leo’s Tutorials"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="leo_toc.html">Leo 6.7.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="tutorial.html" accesskey="U">Leo’s Tutorials</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Leo in 10 Minutes</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="leo-in-10-minutes">
<h1>Leo in 10 Minutes<a class="headerlink" href="#leo-in-10-minutes" title="Permalink to this heading">¶</a></h1>
<p>This chapter introduces Leo’s most important features and terminology.</p>
<div class="contents local topic" id="contents">
<p class="topic-title">Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#leo-s-main-window" id="id2">Leo’s main window</a></p></li>
<li><p><a class="reference internal" href="#commands" id="id3">Commands</a></p></li>
<li><p><a class="reference internal" href="#outlines-and-clones" id="id4">Outlines and clones</a></p></li>
<li><p><a class="reference internal" href="#leo-directives" id="id5">Leo directives</a></p></li>
<li><p><a class="reference internal" href="#external-files" id="id6">External files</a></p>
<ul>
<li><p><a class="reference internal" href="#file" id="id7">&#64;file</a></p></li>
<li><p><a class="reference internal" href="#markup" id="id8">Markup</a></p></li>
<li><p><a class="reference internal" href="#clean" id="id9">&#64;clean</a></p></li>
<li><p><a class="reference internal" href="#all" id="id10">&#64;all</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#configuring-leo" id="id11">Configuring Leo</a></p></li>
<li><p><a class="reference internal" href="#plugins" id="id12">Plugins</a></p></li>
<li><p><a class="reference internal" href="#scripting-basics" id="id13">Scripting basics</a></p>
<ul>
<li><p><a class="reference internal" href="#scripting-markup" id="id14">Scripting markup</a></p></li>
<li><p><a class="reference internal" href="#c-g-and-p" id="id15">c, g, and p</a></p></li>
<li><p><a class="reference internal" href="#accessing-outline-data" id="id16">Accessing outline data</a></p></li>
<li><p><a class="reference internal" href="#button-and-command-nodes" id="id17">&#64;button and &#64;command nodes</a></p></li>
<li><p><a class="reference internal" href="#autocompletion-and-calltips" id="id18">Autocompletion and calltips</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#summary" id="id19">Summary</a></p></li>
</ul>
</div>
<section id="leo-s-main-window">
<h2><a class="toc-backref" href="#id2">Leo’s main window</a><a class="headerlink" href="#leo-s-main-window" title="Permalink to this heading">¶</a></h2>
<p>Here is a screenshot of Leo’s main window:</p>
<img alt="Screenshot" src="_images/leo-workbook.png" />
<p id="index-0">Leo’s main window consists of an <strong>icon area</strong> just below the menus, an <strong>outline pane</strong> at the top left, a <strong>log pane</strong> at the top right, a <strong>body pane</strong> at the bottom left, and an optional <strong>viewrendered pane</strong> at the bottom right. The <strong>minibuffer</strong> and <strong>status line</strong> lie at the bottom of the main window.</p>
<p>The log pane contains several tabs:</p>
<ul class="simple">
<li><p>The <strong>Log tab</strong> shows messages from Leo.</p></li>
<li><p>The <strong>Find tab</strong> shows the status of Leo’s Find/Replace commands.</p></li>
</ul>
<p>Other tabs may also appear in the log pane:</p>
<ul class="simple">
<li><p>The <strong>Spell tab</strong> controls Leo’s spell-checking.</p></li>
<li><p>The <strong>Completion tab</strong> shows available typing completions.</p></li>
</ul>
<p id="index-1">Leo stores all data in <strong>nodes</strong>. Nodes have <strong>headlines</strong> (shown in the outline pane) and <strong>body text</strong>. The body pane shows the body text of the <strong>presently selected node</strong>, the node whose headline is selected in the outline pane.  Headlines have an <strong>icon box</strong> indicating a node’s status. For example, the icon box has a red border when the node has been changed.</p>
</section>
<section id="commands">
<h2><a class="toc-backref" href="#id3">Commands</a><a class="headerlink" href="#commands" title="Permalink to this heading">¶</a></h2>
<p>Leo has hundreds of commands, described in <a class="reference external" href="commands.html">Leo’s Command Reference</a>. <strong>Very important</strong>: You can (and should) ignore most of these commands at first. You execute commands using <a class="reference external" href="commands.html#key-reference">key bindings</a> or <em>by name</em> in <a class="reference external" href="commands.html#executing-commands-from-the-minibuffer">Leo’s minibuffer</a>, similar to the <a class="reference external" href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Minibuffer.html">Emacs minibuffer</a>.</p>
<p>You could type the full command name in the minibuffer, followed by the <code class="docutils literal notranslate"><span class="pre">&lt;Return&gt;</span></code> key to invoke the command, but that would be <em>way</em> too much work. Instead, you should use <strong>typing completion</strong> to avoid most typing. For example, you can execute the sort-lines commands this way:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="n">Alt</span><span class="o">-</span><span class="n">X</span><span class="o">&gt;</span><span class="n">so</span><span class="o">&lt;</span><span class="n">Tab</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>Now the minibuffer will list the common prefix of all commands that start with “so”, namely:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sort</span><span class="o">-</span>
</pre></div>
</div>
<p>After typing l&lt;Tab&gt; the minibuffer will contain:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sort</span><span class="o">-</span><span class="n">lines</span>
</pre></div>
</div>
<p>Now, just type &lt;Return&gt; to execute the command.  Typing completion quickly becomes second nature.</p>
<p><strong>Very important</strong>: There is no need to remember the exact names of Leo’s commands. Instead, you only need to remember a few common command prefixes, such as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">clone</span><span class="o">-</span><span class="n">find</span>  <span class="n">clone</span><span class="o">-</span><span class="n">find</span> <span class="n">commands</span>
<span class="n">file</span><span class="o">-</span>       <span class="n">file</span> <span class="n">commands</span>
<span class="n">find</span><span class="o">-</span>       <span class="n">find</span> <span class="n">commands</span>
<span class="n">isearch</span><span class="o">-</span>    <span class="n">incremental</span> <span class="n">search</span> <span class="n">commands</span>
<span class="n">leo</span><span class="o">-</span>        <span class="nb">open</span> <span class="o">.</span><span class="n">leo</span> <span class="n">files</span>
<span class="nb">open</span><span class="o">-</span>       <span class="nb">open</span> <span class="n">files</span> <span class="ow">or</span> <span class="n">url</span><span class="s1">&#39;s</span>
<span class="nb">print</span><span class="o">-</span>      <span class="nb">print</span> <span class="n">commands</span>
<span class="n">sort</span><span class="o">-</span>       <span class="n">sort</span> <span class="n">commands</span>
<span class="n">toggle</span><span class="o">-</span>     <span class="n">toggle</span> <span class="n">settings</span> <span class="n">commands</span>
</pre></div>
</div>
<p>The following commands pertain to the minibuffer itself:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">Alt-X</span> <span class="pre">(full-command)</span></code></dt><dd><p>Executes any other command by typing its full name.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Ctrl-P</span> <span class="pre">(repeat-complex-command</span></code></dt><dd><p>Repeats the last command entered by name in the minibuffer.</p>
</dd>
</dl>
<p>The following keys have special meaning in the minibuffer:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">&lt;Return&gt;</span></code></dt><dd><p>Executes the command.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">&lt;Tab&gt;</span></code></dt><dd><p>Shows all valid completions.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">&lt;BackSpace&gt;</span></code></dt><dd><p>Shows more completions.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Ctrl-G</span></code></dt><dd><p>Exits the minibuffer and puts the focus in the body pane.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">UpArrow</span></code></dt><dd><p>Moves backward through command history. The first <code class="docutils literal notranslate"><span class="pre">UpArrow</span></code> is the same as <code class="docutils literal notranslate"><span class="pre">Ctrl-P</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">DownArrow</span></code></dt><dd><p>Moves forward through command history.</p>
</dd>
</dl>
</section>
<section id="outlines-and-clones">
<h2><a class="toc-backref" href="#id4">Outlines and clones</a><a class="headerlink" href="#outlines-and-clones" title="Permalink to this heading">¶</a></h2>
<p>Leo is a <a class="reference external" href="commands.html#outline-commands">full-featured outliner</a>, with commands to insert, delete, move, hoist, promote and demote nodes.</p>
<p><strong>Clones</strong> are a unique feature of Leo. Any outline node may be cloned. Cloned nodes are actually the <em>same</em> node, but they appear in different places in the outline. Changes to any clone affect all other clones of that node, <em>including their descendants</em>. For example, suppose the A` nodes are clones of each other:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>- A`
    - B
    - C
- D
- A`
    - B
    - C
</pre></div>
</div>
<p>Moving C right gives this outline:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>- A`
    - B
        - C
- D
- A`
    - B
        - C
</pre></div>
</div>
<p id="clone-find-commands">Clones allow you to create multiple views of data within a single outline. For example, Leo’s <a class="reference internal" href="#clone-find-commands">clone-find commands</a> create clones of all found nodes, moving the newly-created clones so they are all children of an <strong>organizer node</strong> describing the search. The organizer node is a new view of the outline’s data, one focused on the found nodes!</p>
</section>
<section id="leo-directives">
<h2><a class="toc-backref" href="#id5">Leo directives</a><a class="headerlink" href="#leo-directives" title="Permalink to this heading">¶</a></h2>
<p id="index-2">Leo <strong>directives</strong> control Leo’s operations. Directives start with <code class="docutils literal notranslate"><span class="pre">&#64;</span></code> in the leftmost column of body text. Directives <strong>apply to descendants</strong> unless overridden in descendant nodes.</p>
<p id="index-3">The <strong>&#64;color</strong>, <strong>&#64;nocolor</strong>, and <strong>&#64;nocolor-node</strong> directives control syntax coloring. <strong>Note</strong>: Nodes containing multiple color directives do <em>not</em> affect the coloring of descendant nodes:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@color</span>
<span class="nd">@nocolor</span>
<span class="nd">@nocolor</span><span class="o">-</span><span class="n">node</span>
</pre></div>
</div>
<p id="index-4">The <strong>&#64;language</strong> directive tells which language is in effect:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@language</span> <span class="n">python</span>
<span class="nd">@language</span> <span class="n">c</span>
<span class="nd">@language</span> <span class="n">rest</span> <span class="c1"># restructured text</span>
<span class="nd">@language</span> <span class="n">plain</span> <span class="c1"># plain text: no syntax coloring.</span>
</pre></div>
</div>
<p id="index-5">The <strong>&#64;pagewidth</strong> directive sets the page width used by the reformat-paragraph command. The <strong>&#64;tabwidth</strong> directive controls tabbing. Negative tab widths (recommended for Python) convert tabs to spaces:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@pagewidth</span> <span class="mi">100</span>
<span class="nd">@tabwidth</span> <span class="o">-</span><span class="mi">4</span>
<span class="nd">@tabwidth</span> <span class="mi">8</span>
</pre></div>
</div>
<p id="index-6">The <strong>&#64;wrap</strong> and <strong>&#64;nowrap</strong> enable or disable line wrapping in the body pane:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@nowrap</span>
<span class="nd">@wrap</span>
</pre></div>
</div>
<p>The <strong>&#64;first</strong> directive ensures that lines appear at the very start of an external file. See the next section. Multiple &#64;first directives are allowed. These directives must be the <em>very first</em> lines of body text:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@first</span> <span class="c1"># -*- coding: utf-8 -*-</span>
<span class="nd">@first</span> <span class="c1">#! /usr/bin/env python</span>
</pre></div>
</div>
<p>Leo has many other directives, described in the <a class="reference external" href="directives.html">directives reference page</a>.</p>
</section>
<section id="external-files">
<h2><a class="toc-backref" href="#id6">External files</a><a class="headerlink" href="#external-files" title="Permalink to this heading">¶</a></h2>
<p>Leo outlines can refer to <strong>external files</strong>, files on your file system. Leo quickly loads the files when opening Leo outlines. The following sections discuss only the basics.  See <a class="reference external" href="directives.html">Leo’s Reference Guide</a> for full details.</p>
<section id="file">
<h3><a class="toc-backref" href="#id7">&#64;file</a><a class="headerlink" href="#file" title="Permalink to this heading">¶</a></h3>
<p id="index-7">An <strong>&#64;file node</strong> is a node whose headline starts with <cite>&#64;file</cite> followed by a path to an external file:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@file</span> <span class="n">leoNodes</span><span class="o">.</span><span class="n">py</span>
<span class="nd">@file</span> <span class="o">../../</span><span class="n">notes</span><span class="o">.</span><span class="n">txt</span>
</pre></div>
</div>
<p>The &#64;file node and its descendants represent an external file. Leo updates &#64;file nodes when you change external files outside of Leo. When saving an outline, Leo writes all changed &#64;file trees to their external files.</p>
</section>
<section id="markup">
<h3><a class="toc-backref" href="#id8">Markup</a><a class="headerlink" href="#markup" title="Permalink to this heading">¶</a></h3>
<p id="index-8">Leo’s <strong>markup</strong> tells Leo how to create external files from &#64;file trees. Markup may appear in any body text, and <em>must</em> appear in the body of the &#64;file node itself.</p>
<p>There are two kinds of markup: <strong>section references</strong> (&lt;&lt; this is my section &gt;&gt;) and the <strong>&#64;others</strong> directive. Section references refer to <strong>named nodes</strong>, nodes whose <em>headlines</em> look like a section reference. &#64;others refers to all <em>other</em> (unnamed) nodes. Here is the body text of a typical &#64;file node for a python file:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@first</span> <span class="c1"># -*- coding: utf-8 -*-</span>
<span class="sd">&#39;&#39;&#39;whatever.py&#39;&#39;&#39;</span>
<span class="o">&lt;&lt;</span> <span class="n">imports</span> <span class="o">&gt;&gt;</span>
<span class="nd">@others</span>
<span class="c1"># That&#39;s all, folks</span>
<span class="nd">@language</span> <span class="n">python</span>
<span class="nd">@tabwidth</span> <span class="o">-</span><span class="mi">4</span>
</pre></div>
</div>
<p>A child node must define the &lt;&lt; imports &gt;&gt; node. Other children will typically define classes, methods, functions, and data.</p>
<p>When writing this file, Leo writes the first two lines:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@first</span> <span class="c1"># -*- coding: utf-8 -*-</span>
<span class="sd">&#39;&#39;&#39;whatever.py&#39;&#39;&#39;</span>
</pre></div>
</div>
<p>followed by the <em>body text</em> of the &lt;&lt; imports&gt;&gt; node, followed by the body text of all <em>other</em> nodes, in outline order, followed by the comment # That’s all, folks.</p>
</section>
<section id="clean">
<h3><a class="toc-backref" href="#id9">&#64;clean</a><a class="headerlink" href="#clean" title="Permalink to this heading">¶</a></h3>
<p id="index-9">When writing <strong>file trees</strong>, Leo writes <strong>sentinel comments</strong> into external files. These comments represent outline structure. When writing an &#64;file tree to a .leo file, Leo writes only the root &#64;file node. To avoid sentinels, use <strong>&#64;clean</strong> instead of &#64;file:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@clean</span> <span class="n">leoNodes</span><span class="o">.</span><span class="n">py</span>
<span class="nd">@clean</span> <span class="o">../../</span><span class="n">notes</span><span class="o">.</span><span class="n">txt</span>
</pre></div>
</div>
<p>There is a small cost to &#64;clean: Leo saves the entire &#64;clean tree in the .leo file.</p>
</section>
<section id="all">
<h3><a class="toc-backref" href="#id10">&#64;all</a><a class="headerlink" href="#all" title="Permalink to this heading">¶</a></h3>
<p id="index-10">The <strong>&#64;all</strong> directive tells Leo to write the nodes of an <strong>&#64;file tree</strong> to the external file, <em>ignoring</em> all markup. As a result, Leo writes nodes to the file in <strong>outline order</strong>, the order in which they appear in the outline when all nodes are expanded.</p>
</section>
</section>
<section id="configuring-leo">
<h2><a class="toc-backref" href="#id11">Configuring Leo</a><a class="headerlink" href="#configuring-leo" title="Permalink to this heading">¶</a></h2>
<p id="index-11">Leo uses outlines for just about <em>everything</em>, including configuring Leo:</p>
<ul class="simple">
<li><p><strong>leo/config/leoSettings.leo</strong> contains Leo’s default <strong>global settings</strong>. Don’t change this file unless you are one of Leo’s developers.</p></li>
<li><p><strong>~/myLeoSettings.leo</strong> contains your <strong>personal settings</strong>. Leo will create this file automatically if it doesn’t exist when using the <em>Settings &gt;&gt; Open myLeoSettings</em> menu item. Settings in myLeoSettings.leo override (or add to) the default settings in leoSettings.leo.</p></li>
<li><p>Any other .leo file may also contain <strong>local settings</strong>. Local settings apply only to that file and override all other settings.</p></li>
</ul>
<p><strong>Settings nodes</strong> specify settings.  These nodes <em>must</em> be descendants of an <strong>&#64;settings</strong> node. Moving a settings node out from the &#64;settings tree disables the setting. Headlines start with &#64; followed by a type, and possibly a value.  Here are some examples, with body text shown indented from headlines:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@bool</span> <span class="n">vim_mode</span> <span class="o">=</span> <span class="kc">False</span>

<span class="nd">@color</span> <span class="n">flash_brackets_background_color</span> <span class="o">=</span> <span class="n">red</span>

<span class="nd">@data</span> <span class="k">global</span><span class="o">-</span><span class="n">abbreviations</span>
    <span class="c1"># Body text contains abbreviations.</span>
    <span class="n">date</span><span class="p">;;</span><span class="o">=</span><span class="p">{</span><span class="o">|</span><span class="p">{</span><span class="n">x</span><span class="o">=</span><span class="n">time</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y/%m/</span><span class="si">%d</span><span class="s2">&quot;</span><span class="p">)}</span><span class="o">|</span><span class="p">}</span>
    <span class="n">trace</span><span class="p">;;</span><span class="o">=</span><span class="n">trace</span> <span class="o">=</span> <span class="o">&lt;|</span><span class="nb">bool</span><span class="o">|&gt;</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">g</span><span class="o">.</span><span class="n">unitTesting</span>
    <span class="n">al</span><span class="p">;;</span><span class="o">=</span><span class="nd">@language</span>
    <span class="n">alh</span><span class="p">;;</span><span class="o">=</span><span class="nd">@language</span> <span class="n">html</span>\<span class="n">n</span>
    <span class="n">alj</span><span class="p">;;</span><span class="o">=</span><span class="nd">@language</span> <span class="n">javascript</span>\<span class="n">n</span>
    <span class="n">alm</span><span class="p">;;</span><span class="o">=</span><span class="nd">@language</span> <span class="n">md</span>\<span class="n">n</span>
    <span class="n">alp</span><span class="p">;;</span><span class="o">=</span><span class="nd">@language</span> <span class="n">python</span>\<span class="n">n</span>
    <span class="n">alr</span><span class="p">;;</span><span class="o">=</span><span class="nd">@language</span> <span class="n">rest</span>\<span class="n">n</span><span class="nd">@wrap</span>\<span class="n">n</span>
    <span class="n">nc</span><span class="p">;;</span><span class="o">=</span><span class="nd">@nocolor</span>\<span class="n">n</span>
    <span class="n">ncn</span><span class="p">;;</span><span class="o">=</span><span class="nd">@nocolor</span><span class="o">-</span><span class="n">node</span>\<span class="n">n</span>

<span class="nd">@string</span> <span class="n">script_file_path</span> <span class="o">=</span> <span class="o">../</span><span class="n">test</span><span class="o">/</span><span class="n">scriptFile</span><span class="o">.</span><span class="n">py</span>

<span class="nd">@enabled</span><span class="o">-</span><span class="n">plugins</span>
    <span class="c1"># a list of enabled plugins</span>
    <span class="n">plugins_menu</span><span class="o">.</span><span class="n">py</span>
    <span class="n">free_layout</span><span class="o">.</span><span class="n">py</span>
    <span class="n">mod_scripting</span><span class="o">.</span><span class="n">py</span>
    <span class="n">backlink</span><span class="o">.</span><span class="n">py</span>
    <span class="n">bigdash</span><span class="o">.</span><span class="n">py</span>
    <span class="n">bookmarks</span><span class="o">.</span><span class="n">py</span>
    <span class="n">contextmenu</span><span class="o">.</span><span class="n">py</span>

<span class="nd">@shortcuts</span>
    <span class="c1"># body text contains personal key bindings</span>
    <span class="n">file</span><span class="o">-</span><span class="nb">open</span><span class="o">-</span><span class="n">by</span><span class="o">-</span><span class="n">name</span>   <span class="o">=</span> <span class="n">Ctrl</span><span class="o">-</span><span class="n">O</span>
    <span class="n">save</span><span class="o">-</span><span class="nb">all</span>            <span class="o">=</span> <span class="n">Ctrl</span><span class="o">-</span><span class="n">S</span>
</pre></div>
</div>
<p>For more information, see Leo’s <a class="reference external" href="customizing.html">configuration guide</a>.</p>
</section>
<section id="plugins">
<h2><a class="toc-backref" href="#id12">Plugins</a><a class="headerlink" href="#plugins" title="Permalink to this heading">¶</a></h2>
<p id="index-12"><a class="reference external" href="plugins.html">Leo plugins</a> are Python programs that extend what Leo can do. Plugins reside in the leo/plugins folder. <strong>&#64;enabled-plugins</strong> settings node enable plugins. Leo has dozens of plugins, including:</p>
<ul class="simple">
<li><p><a class="reference external" href="plugins.html#bookmarks-py">bookmarks.py</a> manages and shows bookmarks.</p></li>
<li><p><a class="reference external" href="plugins.html#contextmenu-py">contextmenu.py</a> shows a context menu when you right-click a headline.</p></li>
<li><p><a class="reference external" href="plugins.html#mod-scripting-py">mod_scripting.py</a> supports &#64;button and &#64;command nodes.</p></li>
<li><p><a class="reference external" href="plugins.html#quicksearch-py">quicksearch.py</a> Adds Nav tab for searching.</p></li>
<li><p><a class="reference external" href="plugins.html#todo-py">todo.py</a> provides to-do list and simple project-management capabilities.</p></li>
<li><p><a class="reference external" href="plugins.html#valuespace-py">valuespace.py</a> adds outline-oriented spreadsheet capabilities.</p></li>
<li><p><a class="reference external" href="plugins.html#viewrendered-py">viewrendered.py</a> creates the rendering pane and renders content in it.</p></li>
</ul>
</section>
<section id="scripting-basics">
<h2><a class="toc-backref" href="#id13">Scripting basics</a><a class="headerlink" href="#scripting-basics" title="Permalink to this heading">¶</a></h2>
<p>Non-programmers: feel free to skip this part.</p>
<section id="scripting-markup">
<h3><a class="toc-backref" href="#id14">Scripting markup</a><a class="headerlink" href="#scripting-markup" title="Permalink to this heading">¶</a></h3>
<p>Leo’s markup applies to scripts as well as external files. Leo’s execute-script command <strong>composes</strong> the script from the selected node, using Leo’s markup. For example, this body text defines the top-level part of a script:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="sd">&#39;&#39;&#39;My script&#39;&#39;&#39;</span>
<span class="o">&lt;&lt;</span> <span class="n">imports</span> <span class="o">&gt;&gt;</span>
<span class="k">class</span> <span class="nc">Controller</span><span class="p">:</span>
    <span class="c1"># Child nodes define the methods of this class.</span>
    <span class="nd">@others</span>
<span class="n">Controller</span><span class="p">(</span><span class="n">c</span><span class="p">)</span><span class="o">.</span><span class="n">run</span> <span class="c1"># c *is* defined.</span>
</pre></div>
</div>
<p>Leo recognizes section references only if they appear <em>alone</em> on a line.  Therefore the following are <em>not</em> section references:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># &lt;&lt; reference 1 &gt;&gt;</span>
<span class="s2">&quot; &lt;&lt; reference 2 &gt;&gt;</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">b</span> <span class="o">&lt;&lt;</span> <span class="n">c</span> <span class="o">&gt;&gt;</span> <span class="mi">2</span><span class="p">;</span>
</pre></div>
</div>
</section>
<section id="c-g-and-p">
<h3><a class="toc-backref" href="#id15">c, g, and p</a><a class="headerlink" href="#c-g-and-p" title="Permalink to this heading">¶</a></h3>
<p>The execute-script command pre-defines three names: c, g, and p. <strong>c</strong> is the <a class="reference external" href="tutorial-basics.html#accessing-outline-data">commander</a> of the outline in which the script executes. <strong>g</strong> is the <code class="docutils literal notranslate"><span class="pre">leo.core.leoGlobals</span></code> module, containing dozens of useful functions and classes.  <strong>p</strong> is the <a class="reference external" href="tutorial-scripting.html#positions-and-vnodes">position</a> of the presently selected node.</p>
</section>
<section id="accessing-outline-data">
<h3><a class="toc-backref" href="#id16">Accessing outline data</a><a class="headerlink" href="#accessing-outline-data" title="Permalink to this heading">¶</a></h3>
<p>The <strong>Commander class</strong> defines both a scripting API and a DOM (Document Object Module) giving <em>complete</em> access to all data in an outline.  For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="sd">&#39;&#39;&#39;</span>
<span class="sd">    Print all headlines of the outline, properly indented,</span>
<span class="sd">    with the number of characters in each node&#39;s body text.</span>
<span class="sd">&#39;&#39;&#39;</span>
<span class="c1"># c.all_positions() is a python generator yielding all positions, in outline order.</span>
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">c</span><span class="o">.</span><span class="n">all_positions</span><span class="p">():</span>
    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%3s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span>
        <span class="nb">len</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">b</span><span class="p">),</span>       <span class="c1"># p.b is p&#39;s body text.</span>
        <span class="s1">&#39; &#39;</span><span class="o">*</span><span class="n">p</span><span class="o">.</span><span class="n">level</span><span class="p">(),</span>  <span class="c1"># p.level() is p&#39;s indentation level.</span>
        <span class="n">p</span><span class="o">.</span><span class="n">h</span><span class="p">,</span>            <span class="c1"># p.h is p&#39;s headline.</span>
    <span class="p">))</span>
</pre></div>
</div>
<p>To run this script, put it in the body text of any node and do Ctrl-B, execute-script.</p>
<p>For more information, see Leo’s <a class="reference external" href="tutorial-scripting.html">scripting tutorial</a>.</p>
</section>
<section id="button-and-command-nodes">
<h3><a class="toc-backref" href="#id17">&#64;button and &#64;command nodes</a><a class="headerlink" href="#button-and-command-nodes" title="Permalink to this heading">¶</a></h3>
<p id="index-13"><strong>&#64;command nodes</strong> define a command. Running the command runs a script that can be applied to any outline node. That is, p is bound to the presently selected node, <em>not</em> the &#64;button node. <strong>&#64;button nodes</strong> work the same way, and also create a button in the icon area. Pressing that button runs the command. For example, this node defines the print-tree command bound to Ctrl-9:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@command</span> <span class="nb">print</span><span class="o">-</span><span class="n">tree</span> <span class="nd">@key</span><span class="o">=</span><span class="n">Ctrl</span><span class="o">-</span><span class="mi">9</span> <span class="c1"># in the headline</span>

<span class="sd">&#39;&#39;&#39;</span>
<span class="sd">    Print all headlines of the selected subtree, properly indented,</span>
<span class="sd">    with the number of characters in each node&#39;s body text.</span>
<span class="sd">&#39;&#39;&#39;</span>
<span class="c1"># p.self_and_subtree() is a python generator yielding p and</span>
<span class="c1"># all positions in p&#39;s subtree, in outline order.</span>
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">self_and_subtree</span><span class="p">():</span>
    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%3s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span>
        <span class="nb">len</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">b</span><span class="p">),</span>       <span class="c1"># p.b is position p&#39;s body text.</span>
        <span class="s1">&#39; &#39;</span><span class="o">*</span><span class="n">p</span><span class="o">.</span><span class="n">level</span><span class="p">(),</span>  <span class="c1"># p.level() is p&#39;s indentation level.</span>
        <span class="n">p</span><span class="o">.</span><span class="n">h</span><span class="p">,</span>            <span class="c1"># p.h is p&#39;s headline.</span>
    <span class="p">)</span>
</pre></div>
</div>
</section>
<section id="autocompletion-and-calltips">
<h3><a class="toc-backref" href="#id18">Autocompletion and calltips</a><a class="headerlink" href="#autocompletion-and-calltips" title="Permalink to this heading">¶</a></h3>
<p><strong>Autocompletion</strong> reminds you of all members (functions, methods, ivars, etc.) contained in objects in Leo’s source code, and in Python’s standard library modules. <code class="docutils literal notranslate"><span class="pre">Alt-1</span> <span class="pre">(toggle-autocompleter)</span></code> enables and disables autocompletion. <strong>Note</strong>: Autocompletion can be enabled only when &#64;language python is in effect.</p>
<p>For example, typing just “c.atF” (in the body pane, with autocompletion enabled) automatically inserts “c.atFileCommands” into the body pane, because “c.atFileCommands” is the only possible completion of “c.atF”.</p>
<p>As another example, typing “at.writeA” will show (in an autocompleter tab in the Log pane) all of the write commands in leoAtFile.py:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">writeAll</span><span class="p">:</span><span class="n">method</span>
<span class="n">writeAllHelper</span><span class="p">:</span><span class="n">method</span>
<span class="n">writeAtAutoNodes</span><span class="p">:</span><span class="n">method</span>
<span class="n">writeAtAutoNodesHelper</span><span class="p">:</span><span class="n">method</span>
<span class="n">writeAtShadowNodes</span><span class="p">:</span><span class="n">method</span>
<span class="n">writeAtShadowNodesHelper</span><span class="p">:</span><span class="n">method</span>
</pre></div>
</div>
<p>When a single completion is shown, typing ‘?’ will show the docstring for a method. For example, “c.atFileCommands.write?” shows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Write</span> <span class="n">a</span> <span class="mf">4.</span><span class="n">x</span> <span class="n">derived</span> <span class="n">file</span><span class="o">.</span>
<span class="n">root</span> <span class="ow">is</span> <span class="n">the</span> <span class="n">position</span> <span class="n">of</span> <span class="n">an</span> <span class="o">@&lt;</span><span class="n">file</span><span class="o">&gt;</span> <span class="n">node</span>
</pre></div>
</div>
<p><strong>Calltips</strong> show the expected arguments to functions and methods. <code class="docutils literal notranslate"><span class="pre">Alt-2</span> <span class="pre">(toggle-calltips)</span></code> enables and disables calltips. <code class="docutils literal notranslate"><span class="pre">(</span></code> shows calltips, when &#64;language python is in effect.
<code class="docutils literal notranslate"><span class="pre">&lt;Return&gt;</span></code> or <code class="docutils literal notranslate"><span class="pre">Ctrl-G</span> <span class="pre">(keyboard-quit)</span></code> exits calltips. Calltips work for any Python function or method, including Python’s global functions. Examples:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">g</span><span class="o">.</span><span class="n">toUnicode</span><span class="p">(</span>            <span class="n">g</span><span class="o">.</span><span class="n">toUnicode</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">encoding</span><span class="p">,</span> <span class="n">reportErrors</span><span class="o">=</span><span class="kc">False</span>
<span class="n">c</span><span class="o">.</span><span class="n">widgetWantsFocusNow</span><span class="p">(</span>  <span class="n">c</span><span class="o">.</span><span class="n">widgetWantsFocusNow</span><span class="p">(</span><span class="n">w</span>
<span class="n">reduce</span><span class="p">(</span>                 <span class="n">reduce</span><span class="p">(</span><span class="n">function</span><span class="p">,</span> <span class="n">sequence</span><span class="p">[,</span> <span class="n">initial</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="n">value</span>
</pre></div>
</div>
</section>
</section>
<section id="summary">
<h2><a class="toc-backref" href="#id19">Summary</a><a class="headerlink" href="#summary" title="Permalink to this heading">¶</a></h2>
<p>Leo is a full-featured outliner with the following special features:</p>
<ul class="simple">
<li><p>Directives control how Leo works.</p></li>
<li><p>&#64;file and &#64;clean nodes create external files.</p></li>
<li><p>myLeoSettings.leo specifies your personal settings.</p></li>
<li><p>Plugins extend Leo. &#64;enabled-plugins settings nodes enable plugins.</p></li>
</ul>
<p>For programmers:</p>
<ul class="simple">
<li><p>Leo has an easy-to-use scripting API, giving full access to all data in the outline.</p></li>
<li><p>&#64;button and &#64;command nodes define scripts that can be applied to <em>other</em> nodes.</p></li>
<li><p>Alt-1 enables autocompletion.</p></li>
</ul>
<p>Leo has hundreds of commands, described in <a class="reference external" href="commands.html">Leo’s Command Reference</a>. Please feel free to <a class="reference external" href="https://groups.google.com/forum/#!forum/leo-editor">ask for help</a> at any time.</p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="leo_toc.html">
              <img class="logo" src="_static/LeoLogo.svg" alt="Logo"/>
            </a></p>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="tutorial.html"
                          title="previous chapter">Leo’s Tutorials</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="tutorial-pim.html"
                          title="next chapter">Using Leo as a Personal Information Manager</a></p>
  </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
<div id="sidebarbutton" title="Collapse sidebar">
<span>«</span>
</div>

      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="tutorial-pim.html" title="Using Leo as a Personal Information Manager"
             >next</a> |</li>
        <li class="right" >
          <a href="tutorial.html" title="Leo’s Tutorials"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="leo_toc.html">Leo 6.7.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="tutorial.html" >Leo’s Tutorials</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Leo in 10 Minutes</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 1997-2023, Edward K. Ream.
      Last updated on February 28, 2023.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.3.0.
    </div>
  </body>
</html>